<template>
  <!-- 收付费作业-手工退费录 入页面 -->
  <div class="fillcontain">
    <el-form :model="searchParams" :rules="rules" ref="ruleForm" label-width="120px" class="search_container">
      <el-row>
        <el-col :span="6">
          <el-form-item label="保单号码" prop="chdrNum">
            <el-input v-model="searchParams.chdrNum" placeholder="请输入" clearable></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="付款受理号" prop="payApplNum">
            <el-input v-model="searchParams.payApplNum" placeholder="请输入" clearable></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6" class="text_center">
          <el-button type="primary" icon="el-icon-search" @click="subGetList"></el-button>
          <el-button type="primary" plain icon="el-icon-refresh" @click="resetSearch"></el-button>
        </el-col>
      </el-row>
    </el-form>

    <div class="contain">
      <el-row class="bgfff pb15">
        <el-col :span="24">
          <el-button type="danger" @click="insertUnAutoReFundInfo" plain>新增</el-button>
        </el-col>
      </el-row>
      <div class="table_container">
        <el-table
            v-loading="loading"
            :data="tableData"
            highlight-current-row
            @row-dblclick="unAutoRefundUpdateGo"
            header-cell-class-name="table-header-class"
            style="width:100%">
          <el-table-column
              min-width="120"
              property="payApplNum"
              label="付款受理号"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width="120"
              property="chdrAndGroupNum"
              label="保单号/组号"
              align='center'
              show-overflow-tooltip>
            <!-- <template slot-scope="scope">
                <span class="">
                    68499/72339
                </span>
            </template> -->
          </el-table-column>
          <el-table-column
              min-width="120"
              property="dateTime"
              label="日期"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width="120"
              property="receiptName"
              label="姓名"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width="120"
              property="payerType"
              label="付款方式"
              align='center'
              show-overflow-tooltip :formatter="formatPayType">
          </el-table-column>
          <el-table-column
              min-width="120"
              property="staticAmount"
              label="金额"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width="120"
              property="createBy"
              label="建档人员"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width="120"
              fixed="right"
              label="操作"
              align='center'>
            <template slot-scope="scope">
              <!-- <el-button type="text" size="small" @click="unAutoRefundUpdateGo(scope.row)">修改</el-button>
              <el-button type="text" size="small" @click="deleteUnAutoReFundInfo(scope.row)">删除</el-button> -->

              <span class="operationIcon mr5" @click="unAutoRefundUpdateGo(scope.row)">
                  <!-- 修改 -->
                  <el-tooltip class="item" effect="light" content="修改" placement="top">
                      <i class="el-icon-edit"></i>
                  </el-tooltip>
              </span>
              <span class="operationIcon ml5" @click="deleteUnAutoReFundInfo(scope.row)">
                  <!-- 删除 -->
                  <el-tooltip class="item" effect="light" content="删除" placement="top">
                      <i class="el-icon-delete"></i>
                  </el-tooltip>
              </span>
            </template>
          </el-table-column>
        </el-table>
        <el-row>
          <el-col :span="24">
            <div class="pagination">
              <el-pagination
                  background
                  v-if='paginations.total > 0'
                  :page-sizes="paginations.pageSizes"
                  :page-size="paginations.pageSize"
                  :layout="paginations.layout"
                  :total="paginations.total"
                  :current-page='paginations.pageIndex'
                  @current-change='handleCurrentChange'
                  @size-change='handleSizeChange'>
              </el-pagination>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <!-- 修改弹框 -->
    <el-dialog
        title="修改"
        :visible.sync="unAutoRefundDialog"
        width="60%"
        center>
      <el-form ref="form" :model="form" label-width="120px">
        <el-row>
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">请款部门</label>
            </el-col>
            <el-col :span="6">
              <el-select v-model="form.reqDept" placeholder="" :disabled="updateDisabled">
                <el-option
                    v-for="item in reqDeptOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-col>
            <el-col :span="12" class="pl20">
              <el-radio-group v-model="form.groupAndSelfType" @change="checkChdrNumIfRadioUpdate(form)"
                              :disabled="updateDisabled">
                <el-radio :label="'P'">个单</el-radio>
                <el-radio :label="'C'">组单</el-radio>
              </el-radio-group>
            </el-col>
          </el-col>
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">保单号/<br />组号</label>
            </el-col>
            <el-col :span="18">
              <el-input placeholder="" v-model="form.chdrAndGroupNum" @blur="checkChdrNum(form)" ref="forcusChdrNum"
                        clearable :disabled="updateDisabled"></el-input>
            </el-col>
          </el-col>
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">付款方式</label>
            </el-col>
            <el-col :span="18">
              <el-select v-model="form.payerType" placeholder="" @change="changePayerType(form)"
                         :disabled="updateDisabled">
                <el-option
                    v-for="item in payerTypeOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-col>
          </el-col>
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">受款人ID</label>
            </el-col>
            <el-col :span="18">
              <el-input placeholder="" v-model="form.clntNum" :disabled="!this.clntNumDiasble||updateDisabled"
                        clearable></el-input>
            </el-col>
          </el-col>

          <el-col :span="12" class="common-box">
                      <el-col :span="6" class="common-lab">
                        <label class="labelName">客户类型</label>
                      </el-col>
                      <el-col :span="18">

                               <el-select  placeholder="请选择" v-model="form.clttype"  @change="changeClttype">
                                                          <el-option key="1" label="投保人" value="1">
                                                          </el-option>
                                                          <el-option key="2" label="被保人" value="2">
                                                          </el-option>
                                                      </el-select>

                      </el-col>
                    </el-col>

          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">受款人姓名</label>
            </el-col>
            <el-col :span="18">
              <el-input placeholder="" :disabled="true||updateDisabled" v-model="form.receiptName"
                        clearable></el-input>
            </el-col>
          </el-col>

          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">营销员代码</label>
            </el-col>
            <el-col :span="6">
              <el-input placeholder="" v-model="form.salerNum" @blur="checkSalerNum(form)" clearable
                        :disabled="updateDisabled"></el-input>
            </el-col>
            <el-col :span="6" class="pl5">
              <el-input placeholder="" v-model="form.salerCode" disabled></el-input>
            </el-col>
            <el-col :span="6" class="pl5">
              <el-input placeholder="" v-model="form.salerName" disabled></el-input>
            </el-col>
          </el-col>
          <!-- 银行类型，银行账户 -->
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">银行</label>
            </el-col>
            <el-col :span="18">
              <el-select v-model="form.bankCode" placeholder="" :disabled="disableBankCode||updateDisabled"
                         :formatter="formatAccBank(form)" @change="checkBankCode(form)">
                <el-option
                    v-for="item in bankOption"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-col>
          </el-col>
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">账号</label>
            </el-col>
            <el-col :span="18">
              <el-select v-model="form.bankAccount"
                         placeholder="请选择"
                         clearable
                         @change="changeBankAccount(form)"
                         :disabled="disableBankAccount||updateDisabled">
                <el-option v-for="item in bankacckeyList" :key="item.bankacckey" :label="item.bankacckey"
                           :value="item.bankacckey"></el-option>
              </el-select>
            </el-col>
          </el-col>


          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">累计退费<br />金额</label>
            </el-col>
            <el-col :span="18">
              <el-input placeholder="" v-model="form.staticAmount" :disabled="true||updateDisabled"></el-input>
            </el-col>
          </el-col>
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">请款状态</label>
            </el-col>
            <el-col :span="18">
              <el-select v-model="form.reqStatus" placeholder="" :disabled="disableReqStatus||updateDisabled"
                         :formatter="formatReqStatus(form)">
                <el-option
                    v-for="item in reqStatusOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-col>
          </el-col>
        </el-row>
      </el-form>

      <div class="contain">
        <el-row class="bgfff pb15">
          <el-col :span="24">
            <el-button type="danger" @click="addSubjectInfo" plain :disabled="updateDisabled">新增科目</el-button>
            <el-button type="danger" @click="removeSubjectInfo" plain :disabled="updateDisabled">删除科目</el-button>
          </el-col>
        </el-row>
        <div class="table_container">
          <el-table
              v-loading="loading"
              :data="tableDataInUpdateDialog"
              @row-click="subjectRowClick"
              highlight-current-row
              header-cell-class-name="table-header-class"
              :row-class-name="tableRowClassName"
              style="width:100%" @select='onTableSelect' @selection-change="handleSelectionChange">
            <el-table-column
                type="selection"
                width="55">
            </el-table-column>

            <el-table-column
                min-width="120"
                property="chdrAndGroupNum"
                label="保单号/组号"
                align='left'
                show-overflow-tooltip>
              <template slot-scope="scope">
                <el-input v-model="scope.row.chdrAndGroupNum" placeholder="" :disabled="updateDisabled"></el-input>
              </template>
            </el-table-column>
            <el-table-column
                min-width="120"
                property="benCode"
                label="科目"
                align='left'
                show-overflow-tooltip>
              <template slot-scope="scope">
                <el-select v-model="scope.row.benCode" placeholder="" :formatter="formattBenCodeInfo(scope.row)"
                           :disabled="updateDisabled" @change="changeBenCode(scope.row)">
                  <el-option
                      v-for="item in subjectOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                  </el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column
                min-width="120"
                property="amount"
                label="金额"
                align='left'
                show-overflow-tooltip>
              <template slot-scope="scope">
                <el-input-number
                    v-model="scope.row.amount"
                    :precision="2"
                    :step="1"
                    :max="100000000"
                    :disabled="updateDisabled"></el-input-number>
              </template>
            </el-table-column>
            <el-table-column
                min-width="120"
                property="payerDesc"
                label="付款原因"
                align='left'
                show-overflow-tooltip>
              <template slot-scope="scope">
                <el-select v-model="scope.row.payerDesc" placeholder="" :formatter="formattPayerDescInfo(scope.row)"
                           :disabled="updateDisabled">
                  <el-option
                      v-for="item in payerDescOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                  </el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column
                min-width="120"
                property="sacsCode"
                label="SacsCode"
                align='left'
                show-overflow-tooltip>
              <template slot-scope="scope">
                <el-input v-model="scope.row.sacsCode" placeholder="" :disabled="updateDisabled"></el-input>
              </template>
            </el-table-column>
            <el-table-column
                min-width="120"
                property="sacsType"
                label="SacsType"
                align='left'
                show-overflow-tooltip>
              <template slot-scope="scope">
                <el-input v-model="scope.row.sacsType" placeholder="" :disabled="updateDisabled"></el-input>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
                <el-button @click="closeDailogInfoAndReturnUpdate()">返 回</el-button>
                <el-button v-if="!updateDisabled" @click="saveUnAutoReFundInfoInUpdate(form)"
                           class="Defaultbutton">保 存</el-button>
            </span>
    </el-dialog>

    <!-- 新增弹框 -->
    <el-dialog
        title="新增"
        :visible.sync="AddUnAutoRefundDialog"
        width="60%"
        center>
      <el-form ref="form" :model="form" label-width="120px">
        <el-row>
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">请款部门</label>
            </el-col>
            <el-col :span="6">
              <el-select v-model="form.reqDept" placeholder="">
                <el-option
                    v-for="item in reqDeptOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-col>
            <el-col :span="12" class="pl20">
              <el-radio-group v-model="form.groupAndSelfType" @change="checkChdrNumIfRadioInsert(form)">
                <el-radio :label="'P'">个单</el-radio>
                <el-radio :label="'C'">组单</el-radio>
              </el-radio-group>
            </el-col>
          </el-col>
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">保单号/<br />组号</label>
            </el-col>
            <el-col :span="18">
              <el-input placeholder="" v-model="form.chdrAndGroupNum" @blur="checkChdrNum(form)" ref="forcusChdrNum"
                        clearable></el-input>
            </el-col>
          </el-col>
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">付款方式</label>
            </el-col>
            <el-col :span="18">
              <el-select v-model="form.payerType" placeholder="请选择" @change="changePayerType(form)">
                <el-option
                    v-for="item in payerTypeOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-col>
          </el-col>
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">受款人ID</label>
            </el-col>
            <el-col :span="18">
              <el-input placeholder="" :disabled="!this.clntNumDiasble" v-model="form.clntNum" clearable></el-input>
            </el-col>
          </el-col>
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">受款人姓名</label>
            </el-col>
            <el-col :span="18">
              <el-input placeholder="" v-model="form.receiptName" disabled></el-input>
            </el-col>
          </el-col>

          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">营销员代码</label>
            </el-col>
            <el-col :span="6">
              <el-input placeholder="" v-model="form.salerNum" @blur="checkSalerNum(form)" clearable></el-input>
            </el-col>
            <el-col :span="6" class="pl5">
              <el-input placeholder="" v-model="form.salerCode" disabled></el-input>
            </el-col>
            <el-col :span="6" class="pl5">
              <el-input placeholder="" v-model="form.salerName" disabled></el-input>
            </el-col>
          </el-col>
          <!-- 银行类型，银行账户 -->
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">银行</label>
            </el-col>
            <el-col :span="18">
              <el-select v-model="form.bankCode" placeholder="" :disabled="this.disableBankCode"
                         :formatter="formatAccBank(form)" @change="checkBankCode($event, form)">
                <el-option
                    v-for="item in bankOption"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-col>
          </el-col>
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">账号</label>
            </el-col>
            <el-col :span="18">
              <el-select v-model="form.bankAccount" placeholder="请选择" clearable :disabled="disableBankAccount">
                <el-option v-for="item in bankacckeyList" :key="item.bankacckey" :label="item.bankacckey"
                           :value="item.bankacckey"></el-option>
              </el-select>
              <!--              <el-input placeholder="" v-model="form.bankAccount" :disabled="disableBankAccount"-->
              <!--                        @change="changeBankAccount(form)" clearable></el-input>-->
            </el-col>
          </el-col>

          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">累计退费<br />金额</label>
            </el-col>
            <el-col :span="18">
              <el-input placeholder="" v-model="form.staticAmount" :disabled="true"></el-input>
            </el-col>
          </el-col>
          <el-col :span="12" class="common-box">
            <el-col :span="6" class="common-lab">
              <label class="labelName">请款状态</label>
            </el-col>
            <el-col :span="18">
              <el-select v-model="form.reqStatus" placeholder="" :disabled="disableReqStatus"
                         :formatter="formatReqStatus(form)">
                <el-option
                    v-for="item in reqStatusOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-col>
          </el-col>
        </el-row>
      </el-form>

      <div class="contain">
        <el-row class="bgfff pb15">
          <el-col :span="24">
            <el-button type="danger" @click="addSubjectInfo" plain>新增科目</el-button>
            <el-button type="danger" @click="removeSubjectInfo" plain>删除科目</el-button>
          </el-col>
        </el-row>
        <div class="table_container">
          <el-table
              v-loading="loading"
              :data="tableDataInUpdateDialog"
              @row-click="subjectRowClick"
              highlight-current-row
              header-cell-class-name="table-header-class"
              :row-class-name="tableRowClassName"
              style="width:100%" @select='onTableSelect' @selection-change="handleSelectionChange">
            <el-table-column
                type="selection"
                width="55">
            </el-table-column>

            <el-table-column
                min-width="120"
                property="chdrAndGroupNum"
                label="保单号/组号"
                align='left'
                show-overflow-tooltip>
              <template slot-scope="scope">
                <el-input v-model="scope.row.chdrAndGroupNum" placeholder="" :disabled="updateDisabled"></el-input>
              </template>
            </el-table-column>
            <el-table-column
                min-width="120"
                property="benCode"
                label="科目"
                align='left'
                show-overflow-tooltip>
              <template slot-scope="scope">
                <el-select v-model="scope.row.benCode" placeholder="" :formatter="formattBenCodeInfo(scope.row)"
                           @change="changeBenCode(scope.row)">
                  <el-option
                      v-for="item in subjectOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                  </el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column
                min-width="120"
                property="amount"
                label="金额"
                align='left'
                show-overflow-tooltip>
              <template slot-scope="scope">
                <el-input-number
                    v-model="scope.row.amount"
                    disabled
                    :precision="2"
                    :step="1"
                    :max="100000000"></el-input-number>
              </template>
            </el-table-column>
            <el-table-column
                min-width="120"
                property="payerDesc"
                label="付款原因"
                align='left'
                show-overflow-tooltip>
              <template slot-scope="scope">
                <el-select v-model="scope.row.payerDesc" placeholder="" :formatter="formattPayerDescInfo(scope.row)">
                  <el-option
                      v-for="item in payerDescOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                  </el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column
                min-width="120"
                property="sacsCode"
                label="SacsCode"
                align='left'
                show-overflow-tooltip>
              <template slot-scope="scope">
                <el-input v-model="scope.row.sacsCode" placeholder="" disabled></el-input>
              </template>
            </el-table-column>
            <el-table-column
                min-width="120"
                property="sacsType"
                label="SacsType"
                align='left'
                show-overflow-tooltip>
              <template slot-scope="scope">
                <el-input v-model="scope.row.sacsType" placeholder="" disabled></el-input>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
                <el-button @click="closeDailogInfoAndReturnAdd()">返 回</el-button>
                <el-button @click="saveUnAutoReFundInfoInUpdate(form)" class="Defaultbutton">保 存</el-button>
            </span>
    </el-dialog>

  </div>
</template>

<script>
  import {mapGetters} from 'vuex'
  import constant from '@/utils/constant';
  import moment from 'moment'; //CYQ:20200217-收付费作业-手工退费录入-引入复杂业务时间格式
  import {
    changBankAccount,
    changePayerType,
    checkChdrNumInfo,
    checkOnAddSubject,
    deleteUnAutoReFundInfo,
    findSalerNumInfo,
    findUnAutoReFundIndoBypayApplNum,
    getBaseOperInfo,
    getUnAutoReFundInfoList,
    saveUnAutoReFundInfo,
    selectOptionBankDealStatVo,
    queryPayamt,
    selectOptionPayerReason,
    selectOptionSubCodeVo
  } from '@/api/selloutLock/reFundInfo';

  export default {
    data() {
      return {
        benCodeList: [],//保存所有已存在的科目类型
        valueDate: '',
        radio: 1,
        unAutoRefundDialog: false,//默认隐藏弹框
        AddUnAutoRefundDialog: false,//CYQ:20200226-收付费作业-手工退费录入-新增输入框
        // 查询条件
        rules: {
          chdrNum: [],
          payApplNum: [],
        },
        searchParams: {
          chdrNum: '', //保单号码
          payApplNum: '',//附款受理号
        },
        tableData: [],
        tableDataInUpdateDialog: [],//在修改的弹窗中
        appInfo: {}, //MQZ:修改弹窗的投保人
        insInfo: {}, //MQZ:修改弹窗的被保人
        tableDataInAddDialog: [],//在新增的弹窗中
        tableDataInInsertDialog: [],//CYQ:20200226-收付费作业-手工退费录入-新增输入框
        loading: false,
        //需要给分页组件传的信息
        paginations: {
          total: 0,        // 总数
          pageIndex: 1,  // 当前位于哪页
          pageSize: 10,   // 1页显示多少条
          pageSizes: [5, 10, 15, 20],  //每页显示多少条
          layout: "total, sizes, prev, pager, next, jumper"   // 翻页属性
        },
        pickerOptions1: {
          disabledDate(time) {
            return time.getTime() > Date.now();
          }
        },
        payerDescOptions: [],//CYQ:20200218-收付费作业-手工退费录入-付款原因
        reqDeptOptions: [{label: '新契约', value: 'SCLON'}, {label: '保服', value: 'POS'}],//CYQ:20200218-收付费作业-手工退费录入-情况状态选择
        form: {
          clntNum: '',
          reqDept: 'SCLON',// 请款部门
          groupAndSelfType: 'P',// P:个单 C:组单
          chdrAndGroupNum: '',// 保单号/组号
          payerType: '0',// 付款方式
          clntNumDiasble: '',// 受款人ID
          receiptName: '',// 受款人姓名
          salerNum: '',// 营销员代码
          salerCode: '',// 营销员code
          salerName: '',// 营销员姓名
          bankCode: 'INDU&COMMB',// 银行
          bankAccount: '',// 账号
          staticAmount: '0',// 累计退费金额
          reqStatus: 'AU',// 请款状态
          payerDesc: '',
          srcebus: '',
          clttype: '',
        },//CYQ:20200218-收付费作业-手工退费录入-新增容器
        bankOption: [],//CYQ:20200218-收付费作业-手工退费录入-银行码
        reqStatusOptions: [{label: '建档', value: 'AU'}, {label: '付款', value: 'PR'}],//CYQ:20200218-收付费作业-手工退费录入-情况状态选择
        payerTypeOptions: [//CYQ:20200218-收付费作业-手工退费录入-支付类型
          {label: '现金', value: '0'},
          {label: '支票', value: '1'},
          {label: '自动付款', value: '5'},
          {label: '虚拟支付', value: '7'}
        ],
        subjectOptions: [],//CYQ:20200218-收付费作业-手工退费录入-科目
        subjectsSelectIndenx: null,//CYQ:20200220-收付费作业-手工退费录入-选择某一行的索引
        disableBankAccount: false,//CYQ:20200227-手工退费录入-银行账号
        disableBankCode: false,//CYQ:20200227-手工退费录入-银行类型码
        clntNumDiasble: false,//CYQ:20200227-手工退费录入-客户号输入权限
        benCodeSelectIndex: [],//勾选的行
        benCodeDeleteObjects: [],//CYQ:20200228-收付费作业-手工退费录入-原数据库存在本次被删除的记录。
        operType: '',//CYQ:20200228-收付费作业-手工退费录入-窗口是新增的还是修改的
        disableReqStatus: false,//CYQ:20200228-收付费作业-手工退费录入-请款状态录入
        baseOperInfo: {},//CYQ:维护用户的基本信息,
        updateDisabled: false,
        banerSlectAll: false,//CYQ:20200421-是否允许触发全选机制
        bankacckeyList: [],// 银行帐号列表数据 bankacckey
      }
    },
    created() {
    },
    mounted() {
      this.selectOptionBankCodeVo();
      this.selectOptionSubCodeInfo();
      this.selectPayerDescReason();
      this.getList();
    },
    methods: {
      /* 科目新增下拉框改变 */
      changeBenCode(item) {
        if (this.benCodeList.indexOf(item.benCode) >= 0) {
          this.$message({
            message: "已存在当前科目，请勿重复选择",
            type: 'error'
          });
          item.benCode = "";
        } else {
          const _benCode = this.subjectOptions.filter(_item => {
            if (_item.value == item.benCode) {
              return true;
            }
          })[0].label.split('-');
          item.sacsCode = _benCode[0];
          item.sacsType = _benCode[1];

          const company  = this.form.companyNum;
          const rldgacct = item.chdrAndGroupNum;

          const _params = {
            sacsCode: item.sacsCode,
            sacsTyp: item.sacsType,
            rldgcoy: company,
            rldgacct: rldgacct
          };

          // 后台存储过程查累计退费保额
          this.$store.dispatch('loading/CHANGE_LOADING', true);
          queryPayamt(_params).then(res => {
            this.$store.dispatch('loading/CHANGE_LOADING', false);
            if (res.resultCode == constant.SUCCESS) {
              if (res.data) {
                const payamt = Number(res.data);
                if (payamt <= 0) {
                  this.$message({
                    message: '余额必须为正数!',
                    type: 'error'
                  });
                } else {
                  item.amount = payamt;
                  this.amountInit(); // 初始化累计退费金额
                }
              }
            }
          }).catch(err => {
            this.$store.dispatch('loading/CHANGE_LOADING', false);
          });
        }
      },
      //CYQ:20200421-收付费作业-自动退费资料加解锁-关闭页面
      closeDailogInfoAndReturnUpdate() {
        console.log("CYQ:20200421-收付费作业-自动退费资料加解锁-关闭页面并清除记录!(修改)");
        this.unAutoRefundDialog = false;
        this.form = {};
      },
      //CYQ:20200421-收付费作业-自动退费资料加解锁-关闭页面
      closeDailogInfoAndReturnAdd() {
        console.log("CYQ:20200421-收付费作业-自动退费资料加解锁-关闭页面并清除记录!(新增)");
        this.AddUnAutoRefundDialog = false;
        this.form = {};
      },

      //CYQ:20200310-收付费作业-自动退费资料加解锁-获取用户基本信息
      getBaseOperInfo() {
        console.log("CYQ:20200310-收付费作业-暂缓退费加解锁-获取用户的基本信息!");
        let params = {};
        getBaseOperInfo(params).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
          if (res.resultCode == constant.SUCCESS) {
            console.log("用户基本信息");
            console.log(res.data);
            this.baseOperInfo.companyNum = res.data.companyNum;
          }
        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })
      },

      //CYQ:20200306-收付费作业-手工退费录入-银行银行状态校验
      checkBankCode(_event, row) {
        console.log('银行名称代码:', _event);
      },
      //CYQ:20200228-收付费作业-手工退费录入-请款状态
      formatReqStatus(row) {
        if (this.operType == 'add') {
          console.log("CYQ:新增时请款状态默认为建档,且封锁");
          this.form.reqStatus = 'AU';
          this.disableReqStatus = true;
        } else {
          console.log("CYQ:非新增-请款状态不再封锁!");
          this.disableReqStatus = false;
        }
        for (const i in this.reqStatusOptions) {
          const op = this.reqStatusOptions[i];
          if (row.reqStatus == op.value) {
            return op.label;
          }
        }
      },
      //把每一行的索引放进row
      tableRowClassName({row, rowIndex}) {
        row.rowNum = rowIndex;
      },
      //CYQ:20200227-收付费作业-手工退费录入-更改支付方式
      changePayerType(row) {
        console.log("CYQ:20200227-收付费作业-手工退费录入-更改支付方式");
        if (row.payerType == '0' || row.payerType == '1') {
          this.disableBankAccount = true;
          this.disableBankCode = true;
        } else {
          this.disableBankCode = true;
          this.disableBankAccount = false;
        }

        if (row.chdrAndGroupNum == null || row.chdrAndGroupNum == '') {
          this.$message({
            message: '请输入保单号或者组号!',
            type: 'error'
          });
          return;
        }
        if (row.payerType == '7' || row.payerType == '5') {//7-虚拟支付;5-自动付款
          let params = {
            "clntNum": row.clntNum,
            "companyNum": row.companyNum,
            "groupAndSelfType": row.groupAndSelfType,
            "payerType": row.payerType,
            "chdrNum": row.chdrAndGroupNum
          };
          console.log("---支付方式校验结果:" + JSON.stringify(params));
          this.bankacckeyList = [];
          this.$store.dispatch('loading/CHANGE_LOADING', true);
          changePayerType(params).then(res => {
            this.$store.dispatch('loading/CHANGE_LOADING', false);
            console.log(res.data);
            if (res.resultCode == '0') {
              if (res.data != null && res.data.length > 0) {
                row.bankCode = res.data[0].bankkey;
                this.bankacckeyList = res.data;
              }
              console.log("支付方式校验结果:" + JSON.stringify(res.resultMsg));
            } else {
              row.payerType = '0';
            }
          }).catch(err => {
            this.$store.dispatch('loading/CHANGE_LOADING', false);
          });

          if (row.groupAndSelfType == 'C' && row.payerType == '5') {
            this.$message({
              message: '集体汇缴件不能为自动转账!',
              type: 'error'
            });
            row.payerType = '0';
          }
        }
      },
      //CYQ:20200226-收付费作业-手工退费录入-更改银行账户时候进行校验
      changeBankAccount(row) {
        console.log("CYQ:20200228-收付费作业-手工退费录入-更改银行账户时候进行校验!");
        if (row.bankAccount == null || row.bankAccount == '') {
          return false;
        }
        let params = {
          "clntNum": row.clntNum,
          "companyNum": row.companyNum,
          "bankCode": row.bankCode,
          "bankAccount": row.bankAccount,
          "branch": row.branch
        }

        console.log("---校验银行账户的信息:" + JSON.stringify(params));
        this.$store.dispatch('loading/CHANGE_LOADING', true);
        changBankAccount(params).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
          console.log(res.data);
          if (res.resultCode == '0') {
            if (res.data != null && res.data != '') {
              this.form.bankCode = res.data;
            }
            console.log("---银行账户校验结果:" + JSON.stringify(res.resultMsg));
          } else {
            this.form.chdrNum = '';

          }
        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })
      },
      //CYQ:20200219-收付费作业-手工退费录入-保单/组号输入校验
      checkChdrNum(row) {
        console.log("CYQ:20200220-手工退费录入-开始校验保单号是否重复，是否被锁定，个单时公司是否正确，组单时是否存在记录!");
        if (row.chdrAndGroupNum == null || row.chdrAndGroupNum == '') {
          this.$message({
            message: '保单号不允许为空!',
            type: 'error'
          });
          //this.$refs.forcusChdrNum.focus();
          return false;
        }

        if (row.chdrAndGroupNum.length != 8) {
          this.$message({
            message: '保单号必须为8位!',
            type: 'error'
          });
          return false;
        }

        if (row.companyNum == null || row.companyNum == '') {
          row.companyNum = this.baseOperInfo.companyNum;
        }


        let paramsCheckChdrNum = {
          "companyNum": row.companyNum,
          "chdrAndGroupNum": row.chdrAndGroupNum,
          "groupAndSelfType": row.groupAndSelfType//个单/组单
        }
        console.log(paramsCheckChdrNum);
        checkChdrNumInfo(paramsCheckChdrNum).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
          console.log("---保单号校验结果:" + JSON.stringify(res.data));
          if (res.resultCode == constant.SUCCESS) {
            this.paginations.total = res.data.total;
            this.form.clntNum = res.data.clntNum;
            this.form.salerCode = res.data.salerCode;
            this.form.salerNum = res.data.salerNum;
            this.form.salerName = res.data.salerName;
            this.form.receiptName = res.data.receiptName;
            this.form.payerType = res.data.payerType;
            this.form.bankCode = res.data.bankCode;
            this.form.payerDesc = res.data.payerDesc;
            this.form.srcebus = res.data.srcebus;

            if (this.form.payerType == '5' || this.form.payerType == '7') {
              // 付款方式：5-自动付款/7-虚拟支付时校验并刷新帐号下拉数据
              this.changePayerType(this.form);
            }
            if (this.form.salerNum && this.form.salerNum.trim().length > 0) {
              // 根据营销员代码更新营销员信息
              this.checkSalerNum(this.form);
            }
          } else {

            this.$refs.forcusChdrNum.focus();
            return false;
          }
        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
          this.$refs.forcusChdrNum.focus();
        })

      },
      //CYQ:20200226-收付费作业-手工退费录入-新增
      insertUnAutoReFundInfo() {
        console.log("CYQ:20200226-收付费作业-手工退费录入-点击新增按钮!");
        this.tableDataInUpdateDialog = [];
        this.getBaseOperInfo();
        this.AddUnAutoRefundDialog = true;
        this.tableDataInInsertDialog = [];
        this.benCodeDeleteObjects = [];
        this.benCodeSelectIndex = [];
        this.operType = 'add';

        // 新增表单数据初始化
        this.form = {
          clntNum: '',
          reqDept: 'SCLON',// 请款部门
          groupAndSelfType: 'P',// P:个单 C:组单
          chdrAndGroupNum: '',// 保单号/组号
          payerType: '0',// 付款方式
          clntNumDiasble: '',// 受款人ID
          receiptName: '',// 受款人姓名
          salerNum: '',// 营销员代码
          salerCode: '',// 营销员code
          salerName: '',// 营销员姓名
          bankCode: 'INDU&COMMB',// 银行
          bankAccount: '',// 账号
          staticAmount: '0',// 累计退费金额
          reqStatus: 'AU',// 请款状态
          payerDesc: '',
          srcebus: '',
          unAutoReFundSubjectList: [],
          unAutoReFundSubjectDeleteList: [],
          companyNum: this.baseOperInfo.companyNum,
        };
        console.log("公司码:" + this.form.companyNum);
      },
      // ZDH:20200514-累计退费金额初始化
      amountInit() {
        let staticAmount = 0;
        this.tableDataInUpdateDialog.forEach(item => {
          staticAmount += item.amount;
        });
        this.form.staticAmount = staticAmount;
      },
      //CYQ:20200226-收付费作业-手工退费录入-删除记录
      deleteUnAutoReFundInfo(row) {
        console.log("CYQ:20200220-收付费作业-手工退费录入-删除数据!");
        if (row.reqStatus == 'PR') {
          this.$message({
            message: "请款状态为[PR-付款]的单不允许删除。",
            type: 'error'
          });
          return;
        }
        this.$confirm('确定删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let params = {
            "unAutoReFund": row
          }

          //校验
          if (params.unAutoReFund.reqStatus != null && params.unAutoReFund.reqStatus == 'PR') {
            this.$message({
              message: "请注意：请款状态为[PR-付款]的单不允许删除。",
              type: 'error'
            });
            return false;
          }

          console.log("删除记录的信息:" + JSON.stringify(params.unAutoReFund));
          this.$store.dispatch('loading/CHANGE_LOADING', true);
          deleteUnAutoReFundInfo(params).then(res => {
            this.$store.dispatch('loading/CHANGE_LOADING', false);
            console.log(res.data);
            if (res.resultCode == '0') {
              this.$message({
                message: res.resultMsg,
                type: 'success'
              });
              this.getList2();
            } else {
              this.form.chdrNum = '';

              this.getList2();
            }
          }).catch(err => {
            this.$store.dispatch('loading/CHANGE_LOADING', false);
          })
        }).catch(() => {
        });
      },
      //CYQ:20200228-收付费作业-手工退费录入 -保存数据
      saveUnAutoReFundInfoInUpdate(form) {
        console.log("CYQ:20200220-收付费作业-手工退费录入-保存数据!");
        console.log(this.form);
        //1、将修改的数据赋值下来
        if (form.groupAndSelfType == 'C' && form.payerType == '5') {
          this.$message({
            message: '退费方式不能为自动付款!',
            type: 'error'
          });
          return false;
        }

        if (form.staticAmount <= 0) {
          this.$message({
            message: '退费金额不能小于零!',
            type: 'error'
          });
          return false;
        }

        //不是数字并且没有8位
        if (isNaN(form.clntNum) || form.clntNum.length != 8) {
          this.$message({
            message: '请输入正确的客户号代码!',
            type: 'error'
          });
          return false;
        }


        if (isNaN(form.salerNum) || form.salerNum.length != 8) {
          this.$message({
            message: '请输入正确的营销员代码!',
            type: 'error'
          });
          return false;
        }


        if (form.payerType == '5' && (form.bankCode == null || form.bankCode == '')) {
          this.$message({
            message: '自动转账类型的银行账号不能为空!',
            type: 'error'
          });
          return false;
        }
//				if(form.benCode == null || form.benCode == '' ){
//				    this.$message({
//				        message: '科目不能为空!',
//				        type: 'error'
//				    });
//				    return ;
//				}
        if (!this.tableDataInUpdateDialog || this.tableDataInUpdateDialog.length <= 0) {
          this.$message({
            message: '科目不能为空!',
            type: 'error'
          });
          return;
        }
        //CYQ:20200228-收付费作业-手工退费录入-容器对象合并处理(将删除容器里面的标记改为delete,传递给后端)
        if (this.benCodeDeleteObjects != null || this.benCodeDeleteObjects.length != 0) {
          for (let i = 0; i < this.benCodeDeleteObjects.length; i++) {
            this.benCodeDeleteObjects[i].operTypeInui = 'delete';
          }
          form.unAutoReFundSubjectDeleteList = this.benCodeDeleteObjects;
        }

        form.unAutoReFundSubjectList = this.tableDataInUpdateDialog;
        let params = {
          "unAutoReFund": form,
          "operType": this.operType
        }

        //CYQ：20200228-收付费作业-手工退费录入-所有数据到此分为三个类型:insert的记录为新增，delete为删除,query为更新记录。后端依据此判断
        console.log(params.unAutoReFund);
        this.$store.dispatch('loading/CHANGE_LOADING', true);
        saveUnAutoReFundInfo(params).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
          if (res.resultCode == constant.SUCCESS) {
            //console.log(res.data);
            this.$message({
              message: res.resultMsg,
              type: 'success'
            });
            this.unAutoRefundDialog = false;
            this.AddUnAutoRefundDialog = false;

            // 新增成功后，查询显示该条信息
            this.searchParams.chdrNum = form.chdrAndGroupNum;
            this.searchParams.payApplNum = '';
            this.subGetList();
          }
        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })
      },
      ///CYQ:20200226-收付费作业-手工退费录入-更改营销员代码自动赋值
      checkSalerNum(row) {
        console.log("CYQ:20200219-根据营销员代码查询营销员信息，其实际字段名为:" + row.salerNum);
        if (row.salerNum == null || row.salerNum == '') {
          return false;
        }
        let params = {
          "salerNum": row.salerNum,
          "companyNum": row.companyNum,
        }
        //console.log("查询营销员信息的参数:"+JSON.stringify(params));
        findSalerNumInfo(params).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
          if (res.resultCode == constant.SUCCESS) {
            //console.log(res.data);
            row.salerName = res.data.salerName;
            row.salerCode = res.data.salerCode;
          } else {
            return false;
          }
        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })
      },
      //CYQ:20200226-收付费作业-手工退费录入-更改银行名称时自动赋值
      formatAccBank(row) {
        console.log("CYQ:20200213-自动匹配合理的银行字段名，其实际字段名为:" + row.bankCode);
        for (const i in this.bankOption) {
          const op = this.bankOption[i];
          if (row.bankCode == op.value) {
            return op.label;
          }
          if (op.label.indexOf(row.bankCode) != -1) {
            row.bankCode = op.value;
            return op.label;
          }
        }
      },
      //CYQ：20200211-收付费作业-手工退费录入-银行代码列表(为下拉框)
      selectOptionBankCodeVo() {
        console.log("CYQ:20200211-收付费作业-手工退费录入-查询银行列表");
        let params = {};
        selectOptionBankDealStatVo(params).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false)
          if (res.resultCode == constant.SUCCESS) {
            this.bankOption = res.data;
            console.log('银行代码列表:', res.data);
          } else {
            return false;
          }
        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })

      },

      //CYQ:20200218-收付费作业-手工退费录入-更改保单类型进行保单校验
      checkChdrNumIfRadioInsert(row) {
        console.log("CYQ:20200227-收付费作业-手工退费录入-校验客户号权限(新增)");
        if (row.groupAndSelfType == 'P') {
          console.log("新增模式选择个单-->受款人ID不允许输入,清空组单号/保单号");
          this.clntNumDiasble = false;
          this.form.chdrAndGroupNum = '';//默认客户号或者组号为空
          this.form.clntNum = '';
        } else if (row.groupAndSelfType == 'C') {
          console.log("新增模式选择组单-->受款人ID允许输入，清空组单号/保单号");
          this.clntNumDiasble = true;
          this.form.chdrAndGroupNum = '';
        }
      },
      //CYQ:20200218-收付费作业-手工退费录入-更改保单类型进行保单校验
      checkChdrNumIfRadioUpdate(row) {
        console.log("CYQ:20200227-收付费作业-手工退费录入-校验客户号权限(修改)");
        if (row.groupAndSelfType == 'P') {
          console.log("修改模式选择个单-->受款人ID不允许输入");
          //this.form.clntNumDiasble = false;
          this.clntNumDiasble = false; //MQZ
        } else if (row.groupAndSelfType == 'C') {
          this.clntNumDiasble = true;
          this.form.chdrAndGroupNum = '';
          this.form.payerType = '0';
          this.form.bankAccount = '';
          this.form.staticAmount = '0';
          this.form.clntNum = '';
        }
      },
      //CYQ:20200219-收付费作业-手工退费录入-付款方式
      formatPayType(row) {
        if (row.payerType == '0') {
          return "现金";
        } else if (row.payerType == '1') {
          return "支票";
        } else if (row.payerType == '5') {
          return "自动付款";
        } else if (row.payerType == '7') {
          return "虚拟支付";
        } else {
          return "未知";
        }
      },
      //CYQ:20200218-收付费作业-手工退费录入-进入记录前的修改按钮
      unAutoRefundUpdateGo(row) {
        console.log("CYQ:20200220-收付费作业-手工退费录入-进入修改前进行数据查询!");
        this.unAutoRefundDialog = true;
        this.bankacckeyList = [];
        this.form = row;
        console.log(this.form)
        if (this.form.reqStatus == 'PR') {
          this.updateDisabled = true;
        } else {
          this.updateDisabled = false;
        }
        //此处必须初始化，以保证每次处理的科目信息均为对应记录的科目信息
        this.benCodeDeleteObjects = [];
        this.benCodeSelectIndex = [];
        this.operType = 'update';//属于修改记录
        this.getUnAutoReFundInfoBy(this.form);
      },
      //CYQ:20200219-收付费作业-手工退费录入-点击修改进入详情页面
      getUnAutoReFundInfoBy(row) {
        let params = {
          "payApplNum": row.payApplNum,
           "chdrNum": row.chdrAndGroupNum,
        }

        findUnAutoReFundIndoBypayApplNum(params).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false)
          if (res.resultCode == constant.SUCCESS) {
            // this.paginations.total = res.data.total;
            console.log("---渲染查询到的对象:");//CYQ:此处开始表对象渲染
            console.log(res.data);
            for(var i=0;i<res.data.clntpfVOList.length;i++){
               if(res.data.clntpfVOList[i].roleflag=="OW"){
                     this.appInfo=res.data.clntpfVOList[i];
               }
               if(res.data.clntpfVOList[i].roleflag=="IF"){
                      this.insInfo=res.data.clntpfVOList[i];
               }
            }
            this.form = res.data;//表对象
            this.form.reqDept = res.data.reqDept;//请款部门
            this.form.groupAndSelfType = res.data.groupAndSelfType;//个单/组单
            this.form.chdrAndGroupNum = res.data.chdrAndGroupNum;//保单/组号
            this.form.payerType = res.data.payerType;//付款方式
            this.form.clntNum = res.data.clntNum;//受款人ID
            this.form.bankCode = res.data.bankCode;//银行码
            this.form.salerNum = res.data.salerNum;
            this.form.bankAccount = res.data.bankAccount;//银行卡账户
            this.tableDataInUpdateDialog = res.data.unAutoReFundSubjectList;
            if (res.data.staticAmount == '') {
              this.form.staticAmount = '0';
            }
            if (this.tableDataInUpdateDialog.length != 0) {
              console.log("从数据库查询到的记录" + JSON.stringify(this.tableDataInUpdateDialog));
            }
          } else {

            return false;
          }
        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })
      },
      //CYQ:20200218-收付费作业-查询列表
      getList2() {
        console.log("CYQ:20200218-收付费作业-手工退费录入-查询列表！(无提示)");
        this.paginations.total = 0;
        this.tableData = [];
        let params = {
          "chdrNum": this.searchParams.chdrNum,
          "payApplNum": this.searchParams.payApplNum,
          "pageSize": this.paginations.pageSize,
          "pageNumber": this.paginations.pageIndex,
          "orderBy": '',
        }
        this.$store.dispatch('loading/CHANGE_LOADING', true);
        getUnAutoReFundInfoList(params).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
          if (res.resultCode == constant.SUCCESS && res.data && res.data.list.length) {
            this.paginations.total = res.data.total;
            this.tableData = res.data.list;
          } else {

            return false;
          }
        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })
      },
      //CYQ:20200218-收付费作业-查询列表
      getList() {
        console.log("CYQ:20200218-收付费作业-手工退费录入-查询列表！");
        //参数
        this.paginations.total = 0;
        this.tableData = [];
        let params = {
          "chdrNum": this.searchParams.chdrNum,
          "payApplNum": this.searchParams.payApplNum,
          "pageSize": this.paginations.pageSize,
          "pageNumber": this.paginations.pageIndex,
          "orderBy": '',
        }

        //非数字
        if (params.chdrNum != '' && isNaN(params.chdrNum)) {
          this.$message({
            message: '保单号必须为数字!',
            type: 'error'
          });
          return false;
        }

        //非数字
        if (params.payApplNum != '' && isNaN(params.payApplNum)) {
          this.$message({
            message: '付款受理号必须为数字!',
            type: 'error'
          });
          return false;
        }

        //查询
        this.$store.dispatch('loading/CHANGE_LOADING', true)
        getUnAutoReFundInfoList(params).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false)
          if (res.resultCode == constant.SUCCESS && res.data && res.data.list.length) {
            this.paginations.total = res.data.total;
            this.tableData = res.data.list;
            console.log(res.data.list);
            // this.$message({
            //   message: res.resultMsg,
            //   type: 'success'
            // });
          }
        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })
      },
      //CYQ:20200218-收付费作业-手工退费录入-表格多选
      onTableSelect(rows, row) {
        console.log("CYQ:20200220-勾选中整个表格的记录!");
        let selected = rows.length && rows.indexOf(row) !== -1
        //console.log(selected)  // true就是选中，0或者false是取消选中
        console.log(row.rowNum);
        if (selected == true) {
          this.benCodeSelectIndex.push(row.rowNum);
          console.log("添加后:" + this.benCodeSelectIndex);
        } else {
          this.benCodeSelectIndex.splice(this.benCodeSelectIndex.indexOf(row.rowNum), 1);//移除掉一个元素
          console.log("移除后:" + this.benCodeSelectIndex);
        }
      },
      //CYQ:20200218-收付费作业-手工退费录入-子列表点击
      subjectRowClick(row, column, event) {
        console.log("点击全选");
        console.info(row);
        console.info(column);
        console.info(event);
        this.euabSelectIndenx = row.rowNum - 1;
      },
      //CYQ:20200227-收付费作业-手工退费录入-科目代码列表
      selectOptionSubCodeInfo() {
        console.log("CYQ:20200227-收付费作业-手工退费录入-科目代码列表");
        let params = {}
        selectOptionSubCodeVo(params).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
          if (res.resultCode == constant.SUCCESS) {
            this.subjectOptions = res.data;
          } else {

            return false;
          }
        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })
      },
      //CYQ:20200218-收付费作业-手工退费录入-科目代码下拉匹配
      formattBenCodeInfo(row) {
        for (const i in this.subjectOptions) {
          const op = this.subjectOptions[i];
          if (row.benCode == op.value) {
            return op.label;
          } else {
            return '';
          }
        }
      },
      //CYQ:20200227-收付费作业-手工退费录入-付款原因列表
      selectPayerDescReason() {
        console.log("CYQ:20200227-收付费作业-手工退费录入-付款原因下拉查询");
        let params = {}
        selectOptionPayerReason(params).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
          if (res.resultCode == constant.SUCCESS) {
            this.payerDescOptions = res.data;
          } else {

            return false;
          }
        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })
      },
      //CYQ:20200218-收付费作业-手工退费录入-付款原图下拉匹配
      formattPayerDescInfo(row) {
        this.payerDescOptions.forEach(op => {
          if (row.payerDesc == op.value || op.label.indexOf(row.payerDesc) != -1) {
            row.payerDesc = op.value;
          }
        });
      },
      //CYQ：20200228-收付费作业-手工退费录入-移除新增记录的序号
      removeSubjectInfo(index, row) {
        if (this.benCodeSelectIndex.length == 0) {
          this.$message({
            message: '请至少勾选一条记录',
            type: 'error'
          });
          return false;
        }
        this.$confirm('确定删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.banerSlectAll = true;//让全选的触发事件失效,保证不再受到触发事件的影响
          const lenIndexInfo = this.benCodeSelectIndex;
          const lenInfo = lenIndexInfo.length;
          console.log("被勾选的个数：" + lenInfo);
          const indextableDataInUpdateDialog = this.tableDataInUpdateDialog;//将数组赋值到一个常量;(用于赋值的数组，保证索引不变)
          const dialogInfo = indextableDataInUpdateDialog.length; //用于遍历的数组(索引容易变化,索引先获取常量)
          console.log("需要删除的个数:" + dialogInfo);
          for (let i = 0; i < lenInfo; i++) {
            let lenIndexInfoIndex = this.benCodeSelectIndex.indexOf(lenIndexInfo[i]);//获取每次移除后数组后旧数组中的对象位置
            console.log("即将删除的标记:" + this.benCodeSelectIndex[lenIndexInfoIndex]);
            A:for (let j = 0; j < dialogInfo; j++) {
              if (indextableDataInUpdateDialog[j].rowNum == this.benCodeSelectIndex[lenIndexInfoIndex]) {
                console.log("即将被移除的数据:" + this.tableDataInUpdateDialog[j].rowNum);

                //根据老对象中的对象查找并从原数组中移除
                let newInfoIndex = this.tableDataInUpdateDialog.indexOf(indextableDataInUpdateDialog[j]);//下标
                //CYQ：20200228-收付费作业-手工退费录入-如果是在数据库查询出来的非新增的记录，将操作标记更改为delete，并放入备删除的容器中,如果是本次新增的新增与修改均不做任何处理
                if (this.tableDataInUpdateDialog[newInfoIndex].operTypeInui == 'query') {
                  console.log("删除一条来自数据库的数据:" + JSON.stringify(this.tableDataInUpdateDialog[newInfoIndex]));
                  this.benCodeDeleteObjects.push(this.tableDataInUpdateDialog[newInfoIndex]);
                }

                this.tableDataInUpdateDialog.splice(newInfoIndex, 1);
                //this.benCodeSelectIndex.splice(lenIndexInfoIndex,1);//既然容器里面的数据已经被删除，勾选的容器也就应该更新;（CYQ:在for循环里面移除数据会导致对象空指针异常）
                console.log("移除" + j + "+1次后剩余:" + JSON.stringify(this.tableDataInUpdateDialog));
                break A;//在for内循环中移除了数据后索引数组会变小,从而导致所以查不到数据，直接结束一轮阻止未知异常,提高性能。
              }
            }
          }
          console.log("最终展示在页面上的数据:" + JSON.stringify(this.tableDataInUpdateDialog));
          console.log("最终放入删除容器的数据:" + JSON.stringify(this.benCodeDeleteObjects));
          this.resetSubjectsRowNum();
          this.banerSlectAll = false;
          this.amountInit();
        }).catch(() => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
          this.banerSlectAll = false;
        });

      },
      //CYQ：20200228-收付费作业-手工退费录入-维护新增记录的序号
      resetSubjectsRowNum() {
        console.log("更新科目列表的序号");
        for (let i = 0; i < this.tableDataInUpdateDialog.length; i++) {
          this.tableDataInUpdateDialog[i].rowNum = (i + 1) + '';
        }
      },
      //CYQ：20200228-收付费作业-手工退费录入-添加新的科目记录
      addSubjectInfo() {
        console.log("CYQ:20200220-新增科目记录信息-按钮和基础参数处理!");
        /* 保存已经选择的科目 */
        this.benCodeList = [];
        if (this.tableDataInUpdateDialog != null) {
          for (let s = 0; s < this.tableDataInUpdateDialog.length; s++) {
            this.benCodeList.push(this.tableDataInUpdateDialog[s].benCode);
            if (this.tableDataInUpdateDialog[s].amount == null || this.tableDataInUpdateDialog[s].amount == 0) {
              this.$message({
                message: '现有科目金额不能为零,请先进行维护!',
                type: 'error'
              });
              return false;//CYQ:20200419-参数校验
            }
            if (this.tableDataInUpdateDialog[s].benCode == null || this.tableDataInUpdateDialog[s].benCode == "") {
              this.$message({
                message: '现有科目类型不能为空,请先进行维护!',
                type: 'error'
              });
              return false;//CYQ:20200419-参数校验
            }
          }
        }
        let chdrNumAdd = '';
        if (this.form.chdrAndGroupNum == null || this.form.chdrAndGroupNum == '') {
          this.$message({
            message: '请先输入保单号码/组号',
            type: 'error'
          });
          return false;//CYQ:20200419-参数校验
        }

        let params = {
          "companyNum": this.form.companyNum,//公司号
          "chdrNum": this.form.chdrAndGroupNum,//保单号或组号
          "payerType": this.form.payerType,//付款原因
          "groupAndSelfType": this.form.groupAndSelfType//个单/组单
        }

        this.$store.dispatch('loading/CHANGE_LOADING', true);
        checkOnAddSubject(params).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
          if (res.resultCode == constant.SUCCESS) {
            if (res.data != '1') {
              this.$message({
                message: res.resultMsg,
                type: 'success'
              });
            }
          } else {

            return false;
          }
        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })

        let newSubjectInfo = {
          chdrNum: this.form.chdrAndGroupNum,
          amount: 0,
          bathNum: "EUIS",
          benCode: "",
          chdrAndGroupNum: this.form.chdrAndGroupNum,
          companyNum: this.form.companyNum,
          createBy: this.form.createBy,
          createTime: moment(new Date()).format("YYYYMMDD"),
          payApplNum: this.form.clntNum,
          payerDesc: this.form.payerDesc,
          sacsCode: "0",
          sacsType: "0",
          systemDate: moment(new Date()).format("YYYYMMDD"),
          userName: this.form.createBy,
          rowNum: "",//每一行的索引，从0开始
          operTypeInui: "insert",//作为前端向后端传递的操作类型
        }
        this.tableDataInUpdateDialog.push(newSubjectInfo);
        this.resetSubjectsRowNum();
        // console.log("---追加的数据:");
        // console.log(this.unAutoRefundDialog);
        // console.log("---追加的结束线---");
      },

      //CYQ:20200420-收付费作业-手工退费录入-全选填充数据
      handleSelectionChange(val) {
        console.log("");
        if (this.banerSlectAll) {
          return;
        }
        console.log(val);
        if (this.tableDataInUpdateDialog.length == val.length) {
          console.log("CYQ:20200420-收付费作业-手工退费录入-执行了全选");
          this.benCodeSelectIndex = [];
          for (let j = 0; j < val.length; j++) {
            this.benCodeSelectIndex.push(val[j].rowNum);
          }
          console.log("全选后:" + this.benCodeSelectIndex);
        }

        if (val.length == 0) {
          console.log("CYQ:20200420-收付费作业-手工退费录入-放弃了全选");
          this.benCodeSelectIndex = [];
          console.log("全选移除后:" + this.benCodeSelectIndex);
        }
      },
      // 每页多少条切换
      handleSizeChange(pageSize) {
        this.paginations.pageSize = pageSize;
        this.getList();
      },
      // 上下分页
      handleCurrentChange(page) {
        this.paginations.pageIndex = page;
        this.getList();
      },
      // 根据条件查询列表
      subGetList() {
        this.paginations.pageIndex = 1;
        this.getList();
      },
      // 清除查询条件
      resetSearch() {
        this.searchParams.chdrNum = '';
        this.searchParams.payApplNum = '';
      },
      //改变投保人,被保人
      changeClttype() {
                if (this.form.clttype == '1') {
                  this.form.receiptName = this.appInfo.surname;
                  this.form.clntNum = this.appInfo.clntnum;
                } else {
                  this.form.receiptName = this.insInfo.surname;
                  this.form.clntNum = this.insInfo.clntnum;
                }
      }

    },
    computed: {
      ...mapGetters(['tags']),
      reload() {
        return this.$store.state.loading.reload;
      }
    },
    activated() {
      if (this.reload) {
        this.$store.dispatch('loading/CHNAGE_RELOAD', false)
        Object.assign(this.$data, this.$options.data());
      }
    }
  }
</script>

<style lang="less" scoped>
  .fillcontain {
    padding-bottom: 0;
  }

  .contain {
    background: #fff;
    padding: 10px;
    margin-bottom: 20px;
  }

  .pagination {
    padding: 10px 20px;
    text-align: right;
  }

  .operationIcon {
    // padding: 12px;
    border: 1px solid #e5e5e5;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: inline-block;
    cursor: pointer;
    box-shadow: 0 0 3px #f9f9f9;

    .svg-icon {
      font-size: 14px;
      fill: #68a3fc;
    }
  }

  .search_container {
    padding: 20px 20px 0 20px;
  }

  .common-box {
    padding-bottom: 15px;
  }

  .common-lab {
    line-height: normal !important;
    text-align: right;

    .labelName {
      text-align: right;
    }
  }
</style>
